// https://www.lintcode.com/problem/container-with-most-water/description

class Solution {
public:
    /**
     * @param heights: a vector of integers
     * @return: an integer
     */
    int maxArea(vector<int> &heights) {
        int res = 0;
        int l = 0;
        int r = heights.size() - 1;
        while (l < r)
        {
            if (heights[l] > heights[r])
            {
                int tmp = heights[r] * (r - l);
                res = max(tmp, res);
                r--;
            }
            else 
            {
                int tmp = heights[l] * (r - l);
                res = max(tmp, res);
                l++;
            }
        }
        return res;
    }
};